package com.wxzhou.wangzhuan.service;

import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@ApplicationScoped
public class OkHttpConfig {

    // 超时配置
    @ConfigProperty(name = "okhttp.connect.timeout", defaultValue = "2000")
    int connectTimeout;

    @ConfigProperty(name = "okhttp.read.timeout", defaultValue = "5000")
    int readTimeout;

    @ConfigProperty(name = "okhttp.call.timeout", defaultValue = "8000")
    int callTimeout;

    // 连接池配置
    @ConfigProperty(name = "okhttp.pool.max.idle", defaultValue = "30")
    int poolMaxIdle;

    @ConfigProperty(name = "okhttp.pool.keep.alive", defaultValue = "5")
    int poolKeepAlive;

    @ConfigProperty(name = "okhttp.pool.max.per.host", defaultValue = "5")
    int poolMaxPerHost;

    // 并发控制
    @ConfigProperty(name = "okhttp.concurrent.global", defaultValue = "15")
    int concurrentGlobal;

    @ConfigProperty(name = "okhttp.concurrent.per.source", defaultValue = "3")
    int concurrentPerSource;

    // Getter 方法
    public int connectTimeout() {
        return connectTimeout;
    }

    public int readTimeout() {
        return readTimeout;
    }

    public int callTimeout() {
        return callTimeout;
    }

    public int poolMaxIdle() {
        return poolMaxIdle;
    }

    public int poolKeepAlive() {
        return poolKeepAlive;
    }

    public int poolMaxPerHost() {
        return poolMaxPerHost;
    }

    public int concurrentGlobal() {
        return concurrentGlobal;
    }

    public int concurrentPerSource() {
        return concurrentPerSource;
    }
}